package M360;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @author zhangmin
 * @create 2022-09-24 15:03
 */
public class Main {
    public static void main(String[] args){
        Scanner cin=new Scanner(System.in);
        int n1=cin.nextInt(),n2=cin.nextInt(),n3=cin.nextInt();
        cin.nextLine();
        Set<String> zhuyu=new HashSet<>();
        Set<String> weiyu=new HashSet<>();
        Set<String> bingyu=new HashSet<>();
        String[] line1 = cin.nextLine().split(" ");
        zhuyu.addAll(Arrays.asList(line1));
        String[] line2 = cin.nextLine().split(" ");
        weiyu.addAll(Arrays.asList(line2));
        String[] line3 = cin.nextLine().split(" ");
        bingyu.addAll(Arrays.asList(line3));
        int m=cin.nextInt();
        cin.nextLine();
        for (int i = 0; i < m; i++) {
            String[] line = cin.nextLine().split(" ");
            int len=line.length;
            int zhuyu_count=0;
            int weiyu_count=0;
            int bingyu_count=0;
            int index=0;
            boolean flag=false;
            while (index<len){
                String cur=line[index++];
                if (zhuyu.contains(cur)){
                    zhuyu_count++;
                    if (weiyu_count!=0||bingyu_count!=0){
                        System.out.println("NO");
                        flag=true;
                        break;
                    }
                }else if (weiyu.contains(cur)){
                    weiyu_count++;
                    if (weiyu_count>1||zhuyu_count==0||bingyu_count!=0){
                        System.out.println("NO");
                        flag=true;
                        break;
                    }
                }else if (bingyu.contains(cur)){
                    bingyu_count++;
                    if (zhuyu_count==0||bingyu_count==0){
                        System.out.println("NO");
                        flag=true;
                        break;
                    }
                }
            }
            if (flag) {
                continue;
            }else{
                if (zhuyu_count==0||weiyu_count!=1){
                    System.out.println("NO");
                }else {
                    System.out.println("YES");
                }
            }
        }
    }
}
